<template>
  <div id="app">
    <Navigation></Navigation><router-view></router-view>
    <FootBar :items="items" v-if="!$route.meta.abb"></FootBar>
  </div>
</template>


<script>
import Navigation from "./components/Navigation_comm";
import FootBar from "./components/footBar_comm";
export default {
  components: {
    Navigation,
    FootBar,
  },
  data: function () {
    return {
      items: [
        {
          iconName: "iconfont icon-elema",
          title: "外卖",
          to: { name: "First_B" },
        },
        {
          iconName: "iconfont icon-zhinanzhen",
          title: "搜索",
          to: { name: "Search_B" },
        },
        {
          iconName: "iconfont icon-icon-",
          title: "订单",
          to: { name: "" },
        },
        {
          iconName: "iconfont icon-wode",
          title: "我的",
          to: { name: "Mine" },
        },
      ],
      //标记动画名称
      // animationName:''
    };
  },
  watch: {
    $route: function (newV) {
      this.$store.commit("changetab", newV.meta.index == 0 ? false : true);
      this.$store.commit("changeNavState", newV.meta.log == 0 ? true : false);
      this.$store.commit("changeback", newV.meta.keep > 0 ? true : false);
      this.$store.commit("changeseach", newV.meta.keeps == 0 ? true : false);
      this.$store.commit("changelogin", newV.meta.login == 0 ? true : false);
      this.$store.commit("changetitle", newV.meta.title);
      this.$store.commit("changennn", newV.meta.top == 0? false:true);
      // this.$store.commit("changeNavState",)
    },
  },
  created(){
      if (sessionStorage.getItem('store')) {
      this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))));
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener('beforeunload', () => {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state));
    });
  }
};
</script>
<style lang="less">
* {
  margin: 0;
  padding: 0;
}
#app {
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    // color: #2c3e50;
  }
}
</style>